package cn.edu.scau.cmi.yangzhengkai.client.classicsDesignPattern;

import java.util.Scanner;


import cn.edu.scau.cmi.yangzhengkai.simpleFactoryMethod.MeatFactory;
import cn.edu.scau.cmi.yangzhengkai.simpleFactoryMethod.domain.Meat;
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Insets;
import javafx.geometry.Orientation;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.ComboBox;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.layout.FlowPane;
import javafx.scene.layout.HBox;
import javafx.scene.text.Font;
import javafx.scene.text.Text;
import javafx.stage.Stage;

public class SimpleFactoryMethodClient extends Application{

	@Override
	public void start(Stage primaryStage){
		
		
		Text text = new Text("选择你想要制造的肉类:");
		text.setStyle("-fx-font-size:18");
		FlowPane fp = new FlowPane();
	    ComboBox<String> cb = new ComboBox<>();
	    cb.getItems().addAll("beef","chicken","pork");
	    cb.setStyle("-fx-font-size:16");
	        
		Button bu = new Button("确定");
		final Label lb = new Label();
		lb.setStyle("-fx-font-size:18");
		HBox hb = new HBox();
		HBox hb1 = new HBox();
		hb.setSpacing(2);
		hb.getChildren().addAll(text,cb,bu);
		hb.setMargin(text, new Insets(5, 10, 0, 20));
		hb1.getChildren().add(lb);
		hb1.setMargin(lb, new Insets(5, 0, 0, 20));
		fp.setOrientation(Orientation.VERTICAL);
		
		fp.getChildren().addAll(hb,hb1);
		
		bu.setOnAction(new EventHandler<ActionEvent>() {
			
			@Override
			public void handle(ActionEvent event) {
				
					Meat meat = MeatFactory.getMeat(cb.getValue());
					lb.setText(meat.cook());
				
			}
		});
		
		
		Scanner input = new Scanner(System.in);
		
		
		
		Scene scene = new Scene(fp);
		primaryStage.setScene(scene);
		primaryStage.setHeight(500);
		primaryStage.setWidth(1000);
		
		primaryStage.show();
		
		
	}
	
	

	public static void main(String[] args) {
		Application.launch(args);

	}
}
